package cc.eddic.practice.spring.dto;

import cc.eddic.practice.spring.Gender;
import cc.eddic.practice.spring.domain.Student;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.val;
import org.springframework.beans.BeanUtils;

import java.time.LocalDateTime;
@Data
@NoArgsConstructor
@AllArgsConstructor

public class StudentResponse {
    private Long id;
    private String name;
    private Gender gender;
    private String major;
    private LocalDateTime createdOn;
    private LocalDateTime updateOn;
    private Integer version;

    public static StudentResponse from(final Student student){
        val dto = new StudentResponse();
        BeanUtils.copyProperties(student, dto);
        return dto;
    }
}
